{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Empty Task\n"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "using Mosek,Mosek.Ext\n",
    "\n",
    "t = maketask()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We load the file `25fv47.task` which is a liner optimization problem. The file includes solutions.\n",
    "\n",
    "The `show()` functions can be used to format the whole problem or parts of it. `25fv47.task` is too large to be shown fullly, so `show()` will cut off some parts. To show the entire task use `showall()` instead."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Task ''\n",
      "    Minimize\n",
      "        R0000: - 0.1 MSEXP + 0.101 MS1MP - 0.075 LDEXP + 0.076 LD1MP - 0.1 PKEXP + 0.101 PK1MP - 0.0875 RKEXP + 0.0885 RK1MP + 0.2 5C0ST + 0.25 6C0ST + 0.001 CCRFT + 2.275 CRUDE - 1.5303 AABDH + 0.9632 HABDH + 0.3687 JABDH - 1.4254 1AAGJA + 1.007 1BAGJA - 1.1387 EAGJA + 0.9839 1HAGJA + 1.0109 11AGJA  ... (707 terms omitted)\n",
      "    Subject to\n",
      "        F1X.0: = 0.0\n",
      "        2SF145: + BNF64 + HNF64 + 1NF64 + JNF64 + YNF64 = 29.0\n",
      "        2SF089: + HNF89 + 1NF89 = 60.0\n",
      "        2SF129: + BNF80 + HN129 + JN129 + MN129 + YN129 - 90A930 = 73.0\n",
      "        30M00: + HNM00 = 77.0\n",
      "        30M94: + 1HNM94 + 2HNM94 + JNM94 = 27.0\n",
      "        30M91: + HNM90 + 1NM90 + JNM90 = 44.0\n",
      "        30ATK: + BNATK + HNATK + 1NATK + JNATK = 4.0\n",
      "        30PGK: + BNK19 + HNK19 + 1NK19 + JNK19 = 23.0\n",
      "        30G30: + ANG30 + BNG30 + HNG30 + 1NG30 = 44.0\n",
      "        30G17: + ANG17 + BNG17 + HNG17 + 1NG17 + JNG17 + MNG17 - NNG17 = 164.0\n",
      "        30G44: + 1HNG44 + 11NG44 = 31.0\n",
      "        30G22: + ANG22 + BNG22 + HNG22 + 1NG22 + JNG22 + 1MNG22 + YNG22 - 90AS30 = 79.0\n",
      "        30D22: + BND22 + HND22 + 1ND22 = 19.0\n",
      "        30D30: + BND30 + HND30 + 1ND30 = 1.0\n",
      "        30121: + 0.5 HNF21 + 0.9 1NF21 = 4.0\n",
      "        30F52: + 0.5 HNF21 + BNF52 + HNF52 + 1NF52 = 86.0\n",
      "        30F48: + BNF48 + HNF48 + 1NF48 + JNF48 + ZNF48 - 128FNN = 88.0\n",
      "        30128: + 128FNN = 20.0\n",
      "        RB017: + 0.511 2CB002 - CB096 - CB095 - CB084 = 0.0\n",
      "        ... (801 constraints omitted)\n",
      "    Variables\n",
      "        MSEXP ∈ [0.0;+Inf[\n",
      "        MS1MP ∈ [0.0;+Inf[\n",
      "        LDEXP ∈ [0.0;+Inf[\n",
      "        LD1MP ∈ [0.0;+Inf[\n",
      "        PKEXP ∈ [0.0;+Inf[\n",
      "        PK1MP ∈ [0.0;+Inf[\n",
      "        RKEXP ∈ [0.0;+Inf[\n",
      "        RK1MP ∈ [0.0;+Inf[\n",
      "        1G0EXP ∈ [0.0;+Inf[\n",
      "        1G01MP ∈ [0.0;+Inf[\n",
      "        1F0EXP ∈ [0.0;+Inf[\n",
      "        1F01MP ∈ [0.0;+Inf[\n",
      "        5C0ST ∈ [0.0;+Inf[\n",
      "        6C0ST ∈ [0.0;+Inf[\n",
      "        CCRFT ∈ [0.0;+Inf[\n",
      "        CRUDE ∈ [0.0;+Inf[\n",
      "        AABDH ∈ [0.0;+Inf[\n",
      "        HABDH ∈ [0.0;+Inf[\n",
      "        JABDH ∈ [0.0;+Inf[\n",
      "        1AAGJA ∈ [0.0;+Inf[\n",
      "        ... (1551 variable bounds omitted)\n"
     ]
    }
   ],
   "source": [
    "readdata(t,joinpath(Pkg.dir(\"Mosek\"),\"test\",\"25fv47.task\"))\n",
    "\n",
    "show(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Objective('R0000': - 0.1 MSEXP + 0.101 MS1MP - 0.075 LDEXP + 0.076 LD1MP - 0.1 PKEXP + 0.101 PK1MP - 0.0875 RKEXP + 0.0885 RK1MP + 0.2 5C0ST + 0.25 6C0ST + 0.001 CCRFT + 2.275 CRUDE - 1.5303 AABDH + 0.9632 HABDH + 0.3687 JABDH - 1.4254 1AAGJA + 1.007 1BAGJA - 1.1387 EAGJA + 0.9839 1HAGJA + 1.0109 11AGJA  ...(707 terms omitted))"
     ]
    }
   ],
   "source": [
    "show(t[Obj()])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Constraint('2SF145': 29.0 = + BNF64 + HNF64 + 1NF64 + JNF64 + YNF64 )"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "show(t[Con(2)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Variable('MSEXP' ∈ [0.0;+Inf[)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "show(t[Var(1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Interior Solution, status = Unknown\n",
      "    Objective: 5501.846030254401 | 5501.8460280611325\n",
      "    Variable solution\n",
      "        name                          level     dual lower     dual upper     dual conic\n",
      "        MSEXP               :    5.3141e+01    -5.3777e-09     0.0000e+00     0.0000e+00\n",
      "        MS1MP               :    9.0695e-05     1.0000e-03     0.0000e+00     0.0000e+00\n",
      "        LDEXP               :    8.4537e-05     1.0000e-03     0.0000e+00     0.0000e+00\n",
      "        LD1MP               :    3.4227e+01     2.8868e-09     0.0000e+00     0.0000e+00\n",
      "        PKEXP               :    8.5445e-05     1.0000e-03     0.0000e+00     0.0000e+00\n",
      "        PK1MP               :    7.3501e+00     1.1459e-08     0.0000e+00     0.0000e+00\n",
      "        RKEXP               :    8.6610e-05     1.0000e-03     0.0000e+00     0.0000e+00\n",
      "        RK1MP               :    1.7316e+01     3.7289e-09     0.0000e+00     0.0000e+00\n",
      "        1G0EXP              :    2.9831e+02    -2.8936e-08     0.0000e+00     0.0000e+00\n",
      "        1G01MP              :    3.0640e+00     2.8936e-08     0.0000e+00     0.0000e+00\n",
      "        1F0EXP              :    3.5337e+02    -2.6446e-08     0.0000e+00     0.0000e+00\n",
      "        1F01MP              :    2.6324e+00     2.6446e-08     0.0000e+00     0.0000e+00\n",
      "        5C0ST               :    2.0818e+03    -3.9886e-08     0.0000e+00     0.0000e+00\n",
      "        6C0ST               :    0.0000e+00     5.0000e-02     0.0000e+00     0.0000e+00\n",
      "        CCRFT               :    6.2500e+01     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        CRUDE               :    1.2942e+03     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        AABDH               :    2.8170e-06     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        HABDH               :    3.7382e+02     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        JABDH               :    1.3218e+02     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        1AAGJA              :    1.4654e+02     0.0000e+00     0.0000e+00     0.0000e+00\n",
      "        ... (1551 variables omitted)\n",
      "    Constraint solution\n",
      "        name                          level     dual lower     dual upper              y\n",
      "        F1X.0               :    0.0000e+00     0.0000e+00     0.0000e+00    -0.0000e+00\n",
      "        2SF145              :    2.9000e+01     2.8297e+00     0.0000e+00     2.8297e+00\n",
      "        2SF089              :    6.0000e+01     2.9002e+00     0.0000e+00     2.9002e+00\n",
      "        2SF129              :    7.3000e+01     2.7619e+00     0.0000e+00     2.7619e+00\n",
      "        30M00               :    7.7000e+01     9.5324e+00     0.0000e+00     9.5324e+00\n",
      "        30M94               :    2.7000e+01     8.8149e+00     0.0000e+00     8.8149e+00\n",
      "        30M91               :    4.4000e+01     8.3345e+00     0.0000e+00     8.3345e+00\n",
      "        30ATK               :    4.0000e+00     7.3382e+00     0.0000e+00     7.3382e+00\n",
      "        30PGK               :    2.3000e+01     7.0821e+00     0.0000e+00     7.0821e+00\n",
      "        30G30               :    4.4000e+01     6.2145e+00     0.0000e+00     6.2145e+00\n",
      "        30G17               :    1.6400e+02     6.2145e+00     0.0000e+00     6.2145e+00\n",
      "        30G44               :    3.1000e+01     6.1717e+00     0.0000e+00     6.1717e+00\n",
      "        30G22               :    7.9000e+01     6.0318e+00     0.0000e+00     6.0318e+00\n",
      "        30D22               :    1.9000e+01     5.8042e+00     0.0000e+00     5.8042e+00\n",
      "        30D30               :    1.0000e+00     6.0273e+00     0.0000e+00     6.0273e+00\n",
      "        30121               :    4.0000e+00     4.0584e+00     0.0000e+00     4.0584e+00\n",
      "        30F52               :    8.6000e+01     4.0584e+00     0.0000e+00     4.0584e+00\n",
      "        30F48               :    8.8000e+01     2.9224e+00     0.0000e+00     2.9224e+00\n",
      "        30128               :    2.0000e+01     2.9224e+00     0.0000e+00     2.9224e+00\n",
      "        RB017               :    0.0000e+00     2.2373e+00     0.0000e+00     2.2373e+00\n",
      "        ... (801 constraints omitted)\n"
     ]
    }
   ],
   "source": [
    "sol = t[Sol(MSK_SOL_ITR)]\n",
    "show(sol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MSEXP: 53.14086064879275, dual lower: -5.37768665709315e-9, dual upper: 0.0, dual conic: 0.0\n"
     ]
    }
   ],
   "source": [
    "show(sol[Var(1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F1X.0: 0.0, dual lower: 0.0, dual upper: 0.0, dual conic: -0.0\n"
     ]
    }
   ],
   "source": [
    "show(sol[Con(1)])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we load another file, `lj-inner.task`, which is a problem with one semidefinite variable and some second order cones. The file includes solutions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Task 'lownerjohn_inner'\n",
      "    Maximize\n",
      "        #obj: + t[0] \n",
      "    Subject to\n",
      "        qc0[0]: + 2.0 d[0] + 3.0 d[1] - qc0[0].coneslack = 0.0\n",
      "        qc0[1]: - 2.0 C[0,0] - 3.0 C[0,1] - qc0[1].coneslack = -0.0\n",
      "        qc0[2]: - 2.0 C[1,0] - 3.0 C[1,1] - qc0[2].coneslack = -0.0\n",
      "        qc1[0]: + 3.0 d[0] - d[1] - qc1[0].coneslack = -0.0\n",
      "        qc1[1]: - 3.0 C[0,0] + C[0,1] - qc1[1].coneslack = -0.0\n",
      "        qc1[2]: - 3.0 C[1,0] + C[1,1] - qc1[2].coneslack = -0.0\n",
      "        qc2[0]: + d[0] - 4.0 d[1] - qc2[0].coneslack = -11.0\n",
      "        qc2[1]: - C[0,0] + 4.0 C[0,1] - qc2[1].coneslack = -0.0\n",
      "        qc2[2]: - C[1,0] + 4.0 C[1,1] - qc2[2].coneslack = -0.0\n",
      "        qc3[0]: - 3.0 d[0] - 2.0 d[1] - qc3[0].coneslack = -23.0\n",
      "        qc3[1]: + 3.0 C[0,0] + 2.0 C[0,1] - qc3[1].coneslack = -0.0\n",
      "        qc3[2]: + 3.0 C[1,0] + 2.0 C[1,1] - qc3[2].coneslack = -0.0\n",
      "        qc4[0]: - 3.0 d[0] + 4.0 d[1] - qc4[0].coneslack = -17.0\n",
      "        qc4[1]: + 3.0 C[0,0] - 4.0 C[0,1] - qc4[1].coneslack = -0.0\n",
      "        qc4[2]: + 3.0 C[1,0] - 4.0 C[1,1] - qc4[2].coneslack = -0.0\n",
      "        #c16: + #MX1 ⋅ #X̄1 = 0.0\n",
      "        #c17: + #MX2 ⋅ #X̄1 = 0.0\n",
      "        #c18: + #MX3 ⋅ #X̄1 = 0.0\n",
      "        #c19: + #MX4 ⋅ #X̄1 = 0.0\n",
      "        #c20: + C[0,0] + #MX5 ⋅ #X̄1 = 0.0\n",
      "        ... (7 constraints omitted)\n",
      "        qc0[0]: (qc0[0].coneslack,qc0[1].coneslack,qc0[2].coneslack) ∈ 𝒞_q(3)\n",
      "        qc1[0]: (qc1[0].coneslack,qc1[1].coneslack,qc1[2].coneslack) ∈ 𝒞_q(3)\n",
      "        qc2[0]: (qc2[0].coneslack,qc2[1].coneslack,qc2[2].coneslack) ∈ 𝒞_q(3)\n",
      "        qc3[0]: (qc3[0].coneslack,qc3[1].coneslack,qc3[2].coneslack) ∈ 𝒞_q(3)\n",
      "        qc4[0]: (qc4[0].coneslack,qc4[1].coneslack,qc4[2].coneslack) ∈ 𝒞_q(3)\n",
      "        #k6: (#x23,#x24,#x25) ∈ 𝒞_qr(3)\n",
      "    Variables\n",
      "        d[0] ∈ ]-Inf;+Inf[\n",
      "        d[1] ∈ ]-Inf;+Inf[\n",
      "        C[0,0] ∈ ]-Inf;+Inf[\n",
      "        C[0,1] ∈ ]-Inf;+Inf[\n",
      "        C[1,0] ∈ ]-Inf;+Inf[\n",
      "        C[1,1] ∈ ]-Inf;+Inf[\n",
      "        qc0[0].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc0[1].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc0[2].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc1[0].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc1[1].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc1[2].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc2[0].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc2[1].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc2[2].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc3[0].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc3[1].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc3[2].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc4[0].coneslack ∈ ]-Inf;+Inf[\n",
      "        qc4[1].coneslack ∈ ]-Inf;+Inf[\n",
      "        ... (6 variable bounds omitted)\n",
      "        #X̄1 ∈ S(4)\n",
      "    Symmetric matrixes\n",
      "        #MX1 (4): [ (3,1,0.5),(3,3,-1.0) ]\n",
      "        #MX2 (4): [ (4,3,-0.5) ]\n",
      "        #MX3 (4): [ (4,3,-0.5) ]\n",
      "        #MX4 (4): [ (4,2,0.5),(4,4,-1.0) ]\n",
      "        #MX5 (4): [ (1,1,-1.0) ]\n",
      "        #MX6 (4): [ (2,1,-0.5) ]\n",
      "        #MX7 (4): [ (2,1,-0.5) ]\n",
      "        #MX8 (4): [ (2,2,-1.0) ]\n",
      "        #MX9 (4): [ (3,3,1.0) ]\n",
      "        #MX10 (4): [ (4,4,1.0) ]\n"
     ]
    }
   ],
   "source": [
    "readdata(t,joinpath(Pkg.dir(\"Mosek\"),\"test\",\"lj-inner.task\"))\n",
    "show(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SemidefiniteVariable('#X̄1' ∈ 𝒞_S(4))"
     ]
    }
   ],
   "source": [
    "show(t[Barvar(1)])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In constraint `#c16` ... `#c20` we have some terms of the form `#MX1 ⋅ #X̄1`; these are semidefinite terms, i.e. the `#MX1` is a symmetric matrix and `#X̄1` is a symmetric positive semidefinite matrix variable. We can check what the matrixes look like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SparseMatrixCSC{Float64,Int64}\n",
      "[0.0 0.0 0.5 0.0; 0.0 0.0 0.0 0.0; 0.5 0.0 -1.0 0.0; 0.0 0.0 0.0 0.0]\n"
     ]
    }
   ],
   "source": [
    "m = t[Symmat(1)]\n",
    "println(typeof(m))\n",
    "println(full(m))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Interior Solution, status = Optimal\n",
       "    Objective: 2.6454571279494123 | 2.645457125709574\n",
       "    Variable solution\n",
       "        name                          level     dual lower     dual upper     dual conic\n",
       "        d[0]                :    3.2903e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        d[1]                :    1.1774e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        C[0,0]              :    2.9228e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        C[0,1]              :    2.3978e-01    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        C[1,0]              :    2.3978e-01    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        C[1,1]              :    2.4043e+00    -0.0000e+00    -0.0000e+00    -0.0000e+00\n",
       "        qc0[0].coneslack    :    1.0113e+01    -0.0000e+00    -0.0000e+00    -5.6478e-02\n",
       "        qc0[1].coneslack    :   -6.5650e+00    -0.0000e+00    -0.0000e+00    -3.6663e-02\n",
       "        qc0[2].coneslack    :   -7.6923e+00    -0.0000e+00    -0.0000e+00    -4.2960e-02\n",
       "        qc1[0].coneslack    :    8.6935e+00    -0.0000e+00    -0.0000e+00    -4.6425e-02\n",
       "        qc1[1].coneslack    :   -8.5287e+00    -0.0000e+00    -0.0000e+00    -4.5545e-02\n",
       "        qc1[2].coneslack    :    1.6849e+00    -0.0000e+00    -0.0000e+00     8.9985e-03\n",
       "        qc2[0].coneslack    :    9.5806e+00    -0.0000e+00    -0.0000e+00    -5.4059e-02\n",
       "        qc2[1].coneslack    :   -1.9637e+00    -0.0000e+00    -0.0000e+00    -1.1081e-02\n",
       "        qc2[2].coneslack    :    9.3772e+00    -0.0000e+00    -0.0000e+00     5.2911e-02\n",
       "        qc3[0].coneslack    :    1.0774e+01    -0.0000e+00    -0.0000e+00    -5.2526e-02\n",
       "        qc3[1].coneslack    :    9.2480e+00    -0.0000e+00    -0.0000e+00     4.5086e-02\n",
       "        qc3[2].coneslack    :    5.5278e+00    -0.0000e+00    -0.0000e+00     2.6949e-02\n",
       "        qc4[0].coneslack    :    1.1839e+01    -0.0000e+00    -0.0000e+00    -4.9570e-02\n",
       "        qc4[1].coneslack    :    7.8094e+00    -0.0000e+00    -0.0000e+00     3.2699e-02\n",
       "        ... (6 variables omitted)\n",
       "    PSD Variable solution\n",
       "        #X̄1: Symmetric 4 × 4\n",
       "                |   2.92e+00   2.40e-01   2.92e+00   1.20e-01 |        |  -4.54e-01   2.27e-02   4.53e-01   2.97e-13 |\n",
       "            X̄ = |              2.40e+00   1.20e-01   2.40e+00 |    S̄ = |             -5.52e-01   3.52e-13   5.51e-01 |\n",
       "                |                         2.92e+00  -2.82e-15 |        |                        -4.53e-01  -2.27e-02 |\n",
       "                |                                    2.40e+00 |        |                                   -5.51e-01 |\n",
       "    Constraint solution\n",
       "        name                          level     dual lower     dual upper              y\n",
       "        qc0[0]              :    0.0000e+00    -5.6478e-02    -0.0000e+00    -5.6478e-02\n",
       "        qc0[1]              :    0.0000e+00    -3.6663e-02    -0.0000e+00    -3.6663e-02\n",
       "        qc0[2]              :    0.0000e+00    -4.2960e-02    -0.0000e+00    -4.2960e-02\n",
       "        qc1[0]              :   -0.0000e+00    -4.6425e-02    -0.0000e+00    -4.6425e-02\n",
       "        qc1[1]              :   -0.0000e+00    -4.5545e-02    -0.0000e+00    -4.5545e-02\n",
       "        qc1[2]              :   -0.0000e+00    -0.0000e+00    -8.9985e-03     8.9985e-03\n",
       "        qc2[0]              :   -1.1000e+01    -5.4059e-02    -0.0000e+00    -5.4059e-02\n",
       "        qc2[1]              :    0.0000e+00    -1.1081e-02    -0.0000e+00    -1.1081e-02\n",
       "        qc2[2]              :    0.0000e+00    -0.0000e+00    -5.2911e-02     5.2911e-02\n",
       "        qc3[0]              :   -2.3000e+01    -5.2526e-02    -0.0000e+00    -5.2526e-02\n",
       "        qc3[1]              :    0.0000e+00    -0.0000e+00    -4.5086e-02     4.5086e-02\n",
       "        qc3[2]              :    0.0000e+00    -0.0000e+00    -2.6949e-02     2.6949e-02\n",
       "        qc4[0]              :   -1.7000e+01    -4.9570e-02    -0.0000e+00    -4.9570e-02\n",
       "        qc4[1]              :    0.0000e+00    -0.0000e+00    -3.2699e-02     3.2699e-02\n",
       "        qc4[2]              :    0.0000e+00    -3.7256e-02    -0.0000e+00    -3.7256e-02\n",
       "        #c16                :    0.0000e+00    -9.0693e-01    -0.0000e+00    -9.0693e-01\n",
       "        #c17                :    0.0000e+00    -4.1990e-02    -0.0000e+00    -4.1990e-02\n",
       "        #c18                :    0.0000e+00    -3.3285e-03    -0.0000e+00    -3.3285e-03\n",
       "        #c19                :    0.0000e+00    -1.1026e+00    -0.0000e+00    -1.1026e+00\n",
       "        #c20                :    0.0000e+00    -4.5440e-01    -0.0000e+00    -4.5440e-01\n",
       "        ... (7 constraints omitted)\n"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "optimize(t)\n",
    "sol = t[Sol(MSK_SOL_ITR)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we can also check the solution to a single semidefinite variable:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "d[0]: Symmetric 4 × 4\n",
      "      |   2.92e+00   2.40e-01   2.92e+00   1.20e-01 |        |  -4.54e-01   2.27e-02   4.53e-01   2.97e-13 |\n",
      "  X̄ = |              2.40e+00   1.20e-01   2.40e+00 |    S̄ = |             -5.52e-01   3.52e-13   5.51e-01 |\n",
      "      |                         2.92e+00  -2.82e-15 |        |                        -4.53e-01  -2.27e-02 |\n",
      "      |                                    2.40e+00 |        |                                   -5.51e-01 |\n"
     ]
    }
   ],
   "source": [
    "show(sol[Barvar(1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.0",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
